// 判断按钮权限
const judgePower = (power, admin_id, path, btnShow) => {
	let type = ''
	let admin_role_id = ''
	// type 1增 2删 3 改 4查 （有才能操作）
	power.forEach(item => {
		if (item.link == path) {
			//console.log(item.power)
			type = item.power.type.split(',')
			admin_role_id = item.power.admin_role_id.split(',')
		}
	});

	type.forEach(a => {
		if (a == 1) {
			admin_role_id.forEach(b => {
				if (admin_role_id.indexOf(admin_id) == -1) {
					btnShow.add = false
				}
			});
		} else if (a == 2) {
			admin_role_id.forEach(b => {
				if (admin_role_id.indexOf(admin_id) == -1) {
					btnShow.del = false
				}
			});
		} else if (a == 3) {
			admin_role_id.forEach(b => {
				if (admin_role_id.indexOf(admin_id) == -1) {
					btnShow.edit = false
				}
			});
		} else {
			admin_role_id.forEach(b => {
				if (admin_role_id.indexOf(admin_id) == -1) {
					btnShow.search = false
				}
			});
		}
	});
	return btnShow
	/* 	console.log('type',type)
		console.log('admin_role_id',admin_role_id) */
}
export default judgePower
